(function () {
    'use strict';

    var app = angular.module('ModuleService', []);

    app.factory('moduleService', ['httpService', function (httpService) {
        var httpOptions = {
            method: "GET",
            url: "jsonData/module.json",
            encoding: "UTF-8"
        };
        return {
            getModules: function () {
                return httpService.createService(httpOptions).then(
                    function (resp) {
                        return resp.data.modules;
                    });
            },
            openedModules: [],
            currentModule: {},
            openModule: function (module) {
                this.openedModules.push(module);
                this.currentModule = module;
            },
            closeModule: function ($index) {
                this.openedModules.splice($index, 1);
            }
        };
    }]);
})();